package cn.wuqingna.legendgem.api.attribute.imp

import cn.wuqingna.legendgem.LegendGem
import cn.wuqingna.legendgem.api.attribute.AbsAttributeSource
import cn.wuqingna.legendgem.api.attribute.AttributeData
import cn.wuqingna.legendgem.gem.GemManager
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import taboolib.platform.util.isNotAir
import java.util.UUID

class SlotsSource(val uuid: UUID,val slot: Int): AbsAttributeSource() {
    override fun getAttribute(): AttributeData? {
        val player = Bukkit.getPlayer(uuid) ?: return null
        val item = player.inventory.getItem(slot)
        return if (item.isNotAir())
            GemSource(uuid, GemManager.getItemGems(item, player)).getAttribute()
        else
            null
    }
}